<template>
	<view class="box">
		<view class="user-section">
			<text>头像</text>
			<u-avatar :src="src" shape="square" class="tx"></u-avatar>
		</view>
		<u--form labelPosition="left" class="con" ref="uForm">
			<u-form-item label="姓名:" prop="name">
				<view class="">{{name}}</view>
			</u-form-item>
			<u-form-item label="年龄:" prop="name">
				<view class="">{{age}}</view>
			</u-form-item>
			<u-form-item label="性别:" prop="name">
				<view class="">{{sex === 1 ? '男' : '女'}}</view>
			</u-form-item>
			<u-form-item label="出生日期:" prop="name">
				<view class="">{{birthDay}}</view>
			</u-form-item>
			<u-form-item label="手机:" prop="name">
				<view class="">{{phone}}</view>
			</u-form-item>
			<u-form-item label="年级:" prop="name">
				<view class="">{{status}}</view>
			</u-form-item>
		</u--form>
		<view class="btn">
			<u-button type="primary" text="修改" @click="emit"></u-button>
		</view>
		<view class="btn2">
			<u-button type="success" text="返回" @click="back"></u-button>
		</view>
	</view>
</template>

<script>
	import http from "../../http.js"
	export default {
		data() {
			return {
				src: "",
				name: "",
				age: "",
				sex: "",
				birthDay: "",
				phone: "",
				userLevel: "",
				classes: "",
				status: ""
			}
		},
		methods: {
			getList() {
				http({
					url: "/api/student/user/current",
					method: "post"
				}).then(res => {
					if (res.code === 1) {
						const user = res.response
						this.name = user.realName
						this.age = user.age
						this.sex = user.sex
						this.birthDay = user.birthDay
						this.phone = user.phone
						this.userLevel = user.userLevel
						this.classes = user.classes
						this.src = user.imagePath
						this.status = user.userLevel
					}
				})
			},
			emit() {
				uni.navigateTo({
					url: "/pages/useremit/useremit"
				})
			},
			back() {
				uni.switchTab({
					url: "/pages/info/info"
				})
			}
		},
		onLoad() {
			this.getList()
		}
	}
</script>
<style>
	.box {
		padding: 15rpx;
	}

	.user-section {
		display: flex;
		align-items: center;
		width: 750rpx;
		height: 100rpx;
	}

	.btn2 {
		margin-top: 15rpx;
	}
</style>